package com.erdos.core.service.impl;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import com.erdos.common.service.BaseCRUDService;
import com.erdos.core.dao.StateDao;
import com.erdos.core.entity.State;
import com.erdos.core.service.StateService;

public class StateServiceImpl extends BaseCRUDService<State> implements StateService{
	private StateDao stateDao;

	public StateDao getStateDao() {
		return stateDao;
	}

	public void setStateDao(StateDao stateDao) {
		this.stateDao = stateDao;
	}

	/* (non-Javadoc)
	 * @see com.hp.core.service.StateService#findStateByStateId(java.lang.String)
	 */
	public State findStateByStateId(String stateId) {
		Map<String,Object> params=new HashMap<String,Object>();
		params.put("stateId", stateId);
		return stateDao.findUniqueByParams(params);
	}

	/* (non-Javadoc)
	 * @see com.hp.core.service.StateService#findStatesByCategoryAndFacilityId(java.lang.String, java.lang.String)
	 */
	public List<State> findStatesByCategoryAndFacilityId(String category,
			String facilityId) {
		Map<String,Object> params=new HashMap<String, Object>();
		params.put("stateCategory", category);	
		params.put("facilityId", facilityId);
		return stateDao.findByParams(params);
	}

	/* (non-Javadoc)
	 * @see com.hp.core.service.StateService#findStatesMapByCategoryAndFacilityId(java.lang.String, java.lang.String)
	 */
	public Map<String, String> findStatesMapByCategoryAndFacilityId(
			String category, String facilityId) {
		Map<String,String> map=new LinkedHashMap<String,String>();
		List<State> states=this.findStatesByCategoryAndFacilityId(category, facilityId);
		for(State state:states){
			map.put(state.getStateId(), state.getStateDesc());
		}
		return map;
	}
	

}
